package zheezes.protocol.impl.wt.meta;

import java.math.BigDecimal;

import zheezes.util.AbstractSerial;
import zheezes.util.format.NumberFormat;


public class FrzData extends AbstractSerial {
	public static final int SIZE = 15;

	private BigDecimal dosage = new BigDecimal(0);
	private BigDecimal desage = new BigDecimal(0);
	private int mtc;// mt constants
	private int voltage;
	private int eeState;// eeprom state
	private int sw;// status word
	private int rssiRecv;
	private int rssiSend;

	@Override
	public int getBytes(byte[] buf, int offset) {
		int idx = offset;
		idx += NumberFormat.getBytes(buf, idx, dosage, NumberFormat.MICRO, 4, NumberFormat.MODE_BCD);
		idx += NumberFormat.getBytes(buf, idx, desage, NumberFormat.MICRO, 4, NumberFormat.MODE_BCD);
		buf[idx++] = (byte) mtc;
		buf[idx++] = (byte) voltage;
		buf[idx++] = (byte) eeState;
		buf[idx++] = (byte) sw;
		buf[idx++] = (byte) rssiRecv;
		buf[idx++] = (byte) rssiSend;
		return idx - offset;
	}

	@Override
	public int setBytes(byte[] buf, int offset, int max) {
		int idx = offset;
		dosage = NumberFormat.setBytes(buf, idx, 4, NumberFormat.MICRO, NumberFormat.MODE_BCD);
		idx += 4;
		desage = NumberFormat.setBytes(buf, idx, 4, NumberFormat.MICRO, NumberFormat.MODE_BCD);
		idx += 4;
		mtc = buf[idx++];
		voltage = buf[idx++];
		eeState = buf[idx++];
		sw = buf[idx++];
		rssiRecv = buf[idx++];
		rssiSend = buf[idx++];
		
		return idx - offset;
	}

	@Override
	public int size() {
		return SIZE;
	}

	public BigDecimal getDosage() {
		return dosage;
	}

	public void setDosage(BigDecimal dosage) {
		this.dosage = dosage;
	}

	public BigDecimal getDesage() {
		return desage;
	}

	public void setDesage(BigDecimal desage) {
		this.desage = desage;
	}

	public int getMtc() {
		return mtc;
	}

	public void setMtc(int mtc) {
		this.mtc = mtc;
	}

	public int getVoltage() {
		return voltage;
	}

	public void setVoltage(int voltage) {
		this.voltage = voltage;
	}

	public int getEeState() {
		return eeState;
	}

	public void setEeState(int eeState) {
		this.eeState = eeState;
	}

	public int getSw() {
		return sw;
	}

	public void setSw(int sw) {
		this.sw = sw;
	}

	public int getRssiRecv() {
		return rssiRecv;
	}

	public void setRssiRecv(int rssiRecv) {
		this.rssiRecv = rssiRecv;
	}

	public int getRssiSend() {
		return rssiSend;
	}

	public void setRssiSend(int rssiSend) {
		this.rssiSend = rssiSend;
	}
}
